<template>
  <view v-if="shenheStatus == 0" class="record-card flex-col">
    <view class="item-box">
      <view class="item" v-for="(item, index) in list" :key="index">
        <view class="flex-y-center flex-x-sb">
          <view class="left">
            <view class="title">{{ item.md_name }}</view>
            <view class="date">{{ time(item.use_time) }}</view>
          </view>
          <view class="right">-1</view>
        </view>
      </view>
    </view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from '@/components/shenhe/shenhe';
export default {
  components: { Shenhe },
  data() {
    return {
      id: '',
      list: [],
    };
  },
  onLoad(params) {
    if (params.id) {
      this.id = params.id;
    }
    this.getList();
  },
  computed: {
    time() {
      return item => {
        return this.$utils.turnDate(item * 1000);
      };
    },
  },
  methods: {
    async getList() {
      const res = await this.$allrequest.coupon.clerkRecord(
        { sale_id: this.id },
        true
      );
      if (res.code == 0) {
        this.list = res.data;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.record-card {
  color: #262626;
  padding: 24rpx 0;
  background: #f2f2f2;
  min-height: 100vh;
}
.item-box {
  flex: 1;
}
.item {
  background: #fff;
  padding: 0 24rpx;
  > view {
    margin: 0 24rpx;
    padding: 24rpx 0;
    border-bottom: 1px solid #f1f1f1;

    .title {
      line-height: 48rpx;
    }
    .left {
      flex: 1;
      width: 0;
    }
    .right {
      font-size: 36rpx;
      font-weight: 600;
    }
    .date {
      line-height: 34rpx;
      font-size: 24rpx;
      color: #8c8c8c;
    }
  }
  &:nth-last-child(1) > view {
    border: 0;
  }
}
</style>
